using Spring.Context;
using Spring.Context.Support;
using Spring.Objects.Factory.Support;
using System;
namespace AppToolKit.Core.Context.Spring.Register
{
	public class ContextRegisterManager
	{
		private DefaultListableObjectFactory factory_;
		public ContextRegisterManager(IApplicationContext context)
		{
            this.factory_ = (DefaultListableObjectFactory)((XmlApplicationContext)context).ObjectFactory;
		}
		public void Register(string name, Type type, bool singleton)
		{
			RootObjectDefinition rootObjectDefinition = new RootObjectDefinition(type);
            rootObjectDefinition.IsSingleton = singleton;
			this.factory_.RegisterObjectDefinition(name, rootObjectDefinition);
		}
		public RootObjectDefinition CreateDefine(Type type)
		{
			return new RootObjectDefinition(type);
		}
		public string GeneratRegisterName(Type type)
		{
			return type.FullName;
		}
		public void Register(string name, RootObjectDefinition define)
		{
			this.factory_.RegisterObjectDefinition(name, define);
		}
		public void Register(Type type, bool singleton)
		{
			this.Register(type.FullName, type, singleton);
		}
		public void InitObject(string name)
		{
			this.factory_.GetObject(name);
		}
	}
}
